package day04.homework.expand;

public class NumSumDemo {
    public static void main(String[] args) {
        //利用for循环计算：求数字1到100之内，所有偶数的和，并输出
        int sum1 = 0, sum2 = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                sum1 += i;
            } else {
                sum2 += i;
            }
        }
        System.out.println("1-100的偶数和为：" + sum1 + "，奇数和为：" + sum2);
    }
}
